package com.omar.labs.tamtamy.conf;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;

public class JTTAProps extends Properties {
	
	private final static String XML_REQ = ".xml";
    private final static String JSON_REQ = ".json";
    
	private String version = "v0.2";
	private String url = "https://tamtamy.reply.it/tamtamy_api-"+version;
    private String type = XML_REQ;
    private String appName = "jTTA";
    private boolean debug = false;
    
    private String usr = null;
    private String pwd = null;
    

	public JTTAProps() {
		// TODO Auto-generated constructor stub
	}

	public JTTAProps(String prop) {
		super();
		try{		  			  			  
		  File confFile = null;
		  try{
			  confFile = new File(prop);
			  this.load(new FileInputStream(confFile));
		  }catch (Exception ex){
			  confFile = new File("res/"+prop);
			  this.load(new FileInputStream(confFile));
		  }
		  System.out.println("Properties File Path: " + confFile.getAbsolutePath());		  
		  String tmpurl = this.getProperty("URL");
		  version = this.getProperty("VERSION");		  		  		  
		  url = tmpurl+"-"+version;		  
		  type = this.getProperty("TYPE");
		  appName = this.getProperty("APPNAME");
		  debug = Boolean.parseBoolean(this.getProperty("DEBUG"));
		  usr = this.getProperty("USERNAME");
		  pwd = this.getProperty("PASSWORD");
		}catch(Exception ex){
		  ex.printStackTrace();	
		  System.out.println("defaults values");	
		}
	}
	
	public String getUrl(){
		return this.url;
	}
	
	public String getVersion(){
		return this.version;
	}
	
	public String getType(){
		return this.type;	
	}
	
	public String getAppName(){
		return this.appName;
	}
	
	public boolean getDebug(){
		return this.debug;
	}
	
	public String getUsername(){
		return this.usr;
	}
	
	public String getPassword(){
		return this.pwd;
	}
}
